package com.agrm.comment.service;

import com.agrm.model.comment.dto.CommentQuery;
import com.agrm.model.comment.pojo.Comment;
import com.agrm.model.common.dtos.PageRequestDto;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

public interface CommentService extends IService<Comment> {
    /**
     * 分页查询评论列表
     * @param page 分页参数，包含查询条件和分页信息
     * @return 返回分页后的评论数据
     */
    Page<Comment> queryList(PageRequestDto page, CommentQuery query);

    boolean like(Integer id);


    List<Comment> findAll(Comment comment);

    @Cacheable(key = "'all'")
    List<Comment> findAll();

    @Cacheable(key = "'tree'")
    List<Comment> findTree();

    @Cacheable(key = "#goodId + '_tree'")
    List<Comment> findTreeByGoodId(Integer goodId);

    @Cacheable(key = "#id")
    Comment findById(Integer id);

    @CacheEvict(allEntries = true)
    boolean save(Comment comment);

    @CacheEvict(allEntries = true)
    boolean update(Comment comment);

    @CacheEvict(allEntries = true)
    int deleteById(Integer id);



//    boolean reply(Integer id);
}
